public class Demo3 {

    public static int count = 0;

    public static void main(String[] args) throws InterruptedException {

        Thread loke = new Thread();

        Thread t = new Thread(() -> {

            synchronized (loke){
                for (int i = 0; i < 50000; i++) {
                    count++;

                }
            }
        });

        Thread t1 = new Thread(() -> {
            synchronized (loke) {
                for (int i = 0; i < 50000; i++) {
                    count++;
                }
            }
        });

        t.start();
        t1.start();
        t.join();
        System.out.println(t1.getState());
        t1.join();
        System.out.println(count);
    }
}
